function ChatBot.FindPlayer( target )

	players = {}

	if not target then
		return;
	end

	for _, v in ipairs( player.GetAll()) do 
		if string.find( string.lower( v:Nick() ), string.lower( target ) ) != nil then
			table.insert( players, v )
		end
	end

	if #players >1 then
		return nil
	elseif #players <1 then
		return nil
	elseif #players == 1 then
		return players[1]
	end
	
end


function ChatBot.Reply( ply ,text )
	if !ply or ply == nil then
		umsg.Start("ChatBot.Call")
			umsg.String( text )
		umsg.End()
	end
	if ply then
		if ply:IsSuperAdmin() then
			umsg.Start("ChatBot.Call")
				umsg.String( text )
			umsg.End()
		end
	end
end

function ChatBot.SaveTable()
	print("ChatBot : Saving Table contents to " .. ChatBotSettings.File .. "  ... " )
	file.Write( ChatBotSettings.File , TableToKeyValues( Tab ) )
	print("ChatBot : Saved Table contents to " .. ChatBotSettings.File .. " ! " )
end
	
function ChatBot.SaveGreetingsTable()
	print("ChatBot : Saving Greetings Table contents to " .. ChatBotSettings.FileG .. "  ... " )
	file.Write( ChatBotSettings.FileG , TableToKeyValues( greetings ) )
	print("ChatBot : Saved Greetings Table contents to " .. ChatBotSettings.FileG .. " ! " )
end
	
function ChatBot.SaveAdminGreetingsTable()
	print("ChatBot : Saving Admin Greetings Table contents to " .. ChatBotSettings.FileAG .. "  ... " )
	file.Write( ChatBotSettings.FileAG , TableToKeyValues( AdminGreet ) )
	print("ChatBot : Saved Admin Greetings Table contents to " .. ChatBotSettings.FileAG .. " ! " )
end

function ChatBot.SendMessage( message )
	if message != nil then
		umsg.Start("ChatBot.Call")
			umsg.String( message )
		umsg.End()
	end
end

function ChatBot.SendPMessage( pl, message )
	if message != nil then
		umsg.Start("ChatBot.Call", pl)
			umsg.String( message )
		umsg.End()
	end
end

function ChatBot.Add( trig , tab )
	if !Tab[trig] then 
		Tab[trig] = { }
		for k,v in pairs( tab ) do
			table.insert( Tab[trig] , v )
			print("ChatBot : Added chat trigger and response !" )
		end
	else
		for k,v in pairs( tab ) do
			table.insert( Tab[trig] , v )
			print("ChatBot : Added chat trigger and response !" )
		end
	end
end
